﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;
using WaterKit.Base;
using WaterKit.TcpUdp;
using Auction_Server.Business;
using System.Data;

namespace Auction_Server
{
    public partial class BidUserWindow : Window
    {
        public BidUserWindow(string bidUser_No)
        {
            InitializeComponent();

            //读取该用户
            baseDataService baseData = new baseDataService();
            DataRow dr = baseData.getUser(bidUser_No).Rows[0];

            //页面赋值
            lblUserNo.Content = Convert.IsDBNull(dr["BIDUSER_NO"]) ? "" : dr["BIDUSER_NO"];
            lblCompanyNo.Content = Convert.IsDBNull(dr["COMPANY_NO"]) ? "" : dr["COMPANY_NO"];
            lblCompanyName.Content = Convert.IsDBNull(dr["COMPANY_NAME"]) ? "" : dr["COMPANY_NAME"];
            lblCompanyIndustry.Content = Convert.IsDBNull(dr["INDUSTRY"]) ? "" : dr["INDUSTRY"];
            lblCompanyAddr.Content = Convert.IsDBNull(dr["COMPANY_ADD"]) ? "" : dr["COMPANY_ADD"];
            lblCompanyContacter.Content = Convert.IsDBNull(dr["CONTACTER"]) ? "" : dr["CONTACTER"];
            lblCompanyCellphone.Content = Convert.IsDBNull(dr["CELLPHONE"]) ? "" : dr["CELLPHONE"];
            lblCompanyFax.Content = Convert.IsDBNull(dr["FAX"]) ? "" : dr["FAX"];
            lblCompanyMail.Content = Convert.IsDBNull(dr["EMAIL"]) ? "" : dr["EMAIL"];

            //绑定证件列表
            attchLV.DataContext = baseData.getAttch(bidUser_No);
            attchLV.SetBinding(ListView.ItemsSourceProperty, new Binding());
        }

        /// <summary>
        /// 窗体拖动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left) this.DragMove();
        }

        /// <summary>
        /// 关闭应用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCloseApp_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// 该页面退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// 打开附件列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void attchLV_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataRowView dataRow = (DataRowView)this.attchLV.SelectedItem;

            if (dataRow == null)
            {
                MessageBox.Show("请选择相应证件！");
            }
            else
            {
                try
                {
                    System.Diagnostics.Process.Start(AppOpr.GetConfigStrings("productimgPre") + dataRow.Row["ATTACHMENT_PATH"].ToString());
                }
                catch (Exception ex)
                {
                    Log4C.WriteErrLog("打开单位证件失败", ex);
                }
            }
        }
    }
}
